﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
namespace Perovich.GameObjects.Tools.Util
{
    public partial class EntityDefine
    {
        private XmlNode thisNode;
        public EntityDefine(XmlNode node) 
        {
            thisNode = node;
        }
        public IEnumerable<Property>Property
        { 
            get 
            { 
                foreach (XmlNode node in thisNode.SelectNodes("Property")) 
                    yield return new Property(node); 
            }
        }
        public IEnumerable<Component>Component
        { 
            get 
            { 
                foreach (XmlNode node in thisNode.SelectNodes("Component")) 
                    yield return new Component(node); 
            }
        }
        public IEnumerable<Init>Init
        { 
            get 
            { 
                foreach (XmlNode node in thisNode.SelectNodes("Init")) 
                    yield return new Init(node); 
            }
        }
        public IEnumerable<Function>Function
        { 
            get 
            { 
                foreach (XmlNode node in thisNode.SelectNodes("Function")) 
                    yield return new Function(node); 
            }
        }
        public IEnumerable<Interface>Interface
        { 
            get 
            { 
                foreach (XmlNode node in thisNode.SelectNodes("Interface")) 
                    yield return new Interface(node); 
            }
        }
        public IEnumerable<Event>Event
        { 
            get 
            { 
                foreach (XmlNode node in thisNode.SelectNodes("Event")) 
                    yield return new Event(node); 
            }
        }
        public string name
        {
            get
            {
                if (thisNode.Attributes["name"]==null)
                    return null;
                return thisNode.Attributes["name"].Value;
            }
        }
        public string summary
        {
            get
            {
                if (thisNode.Attributes["summary"]==null)
                    return null;
                return thisNode.Attributes["summary"].Value;
            }
        }
    }
    public partial class Property
    {
        private XmlNode thisNode;
        public Property(XmlNode node) 
        {
            thisNode = node;
        }
        public string name
        {
            get
            {
                if (thisNode.Attributes["name"]==null)
                    return null;
                return thisNode.Attributes["name"].Value;
            }
        }
        public string type
        {
            get
            {
                if (thisNode.Attributes["type"]==null)
                    return null;
                return thisNode.Attributes["type"].Value;
            }
        }
        public string access
        {
            get
            {
                if (thisNode.Attributes["access"]==null)
                    return null;
                return thisNode.Attributes["access"].Value;
            }
        }
        public string summary
        {
            get
            {
                if (thisNode.Attributes["summary"]==null)
                    return null;
                return thisNode.Attributes["summary"].Value;
            }
        }
        public string target
        {
            get
            {
                if (thisNode.Attributes["target"]==null)
                    return null;
                return thisNode.Attributes["target"].Value;
            }
        }
        public string returns
        {
            get
            {
                if (thisNode.Attributes["returns"]==null)
                    return null;
                return thisNode.Attributes["returns"].Value;
            }
        }
    }
    public partial class Component
    {
        private XmlNode thisNode;
        public Component(XmlNode node) 
        {
            thisNode = node;
        }
        public string type
        {
            get
            {
                if (thisNode.Attributes["type"]==null)
                    return null;
                return thisNode.Attributes["type"].Value;
            }
        }
    }
    public partial class Init
    {
        private XmlNode thisNode;
        public Init(XmlNode node) 
        {
            thisNode = node;
        }
        public string name
        {
            get
            {
                if (thisNode.Attributes["name"]==null)
                    return null;
                return thisNode.Attributes["name"].Value;
            }
        }
        public string value
        {
            get
            {
                if (thisNode.Attributes["value"]==null)
                    return null;
                return thisNode.Attributes["value"].Value;
            }
        }
    }
    public partial class Function
    {
        private XmlNode thisNode;
        public Function(XmlNode node) 
        {
            thisNode = node;
        }
        public IEnumerable<Param>Param
        { 
            get 
            { 
                foreach (XmlNode node in thisNode.SelectNodes("Param")) 
                    yield return new Param(node); 
            }
        }
        public string Text
        {
            get
            {
                return thisNode.InnerText;
            }
        }
        public string name
        {
            get
            {
                if (thisNode.Attributes["name"]==null)
                    return null;
                return thisNode.Attributes["name"].Value;
            }
        }
        public string type
        {
            get
            {
                if (thisNode.Attributes["type"]==null)
                    return null;
                return thisNode.Attributes["type"].Value;
            }
        }
        public string access
        {
            get
            {
                if (thisNode.Attributes["access"]==null)
                    return null;
                return thisNode.Attributes["access"].Value;
            }
        }
        public string summary
        {
            get
            {
                if (thisNode.Attributes["summary"]==null)
                    return null;
                return thisNode.Attributes["summary"].Value;
            }
        }
        public string returns
        {
            get
            {
                if (thisNode.Attributes["returns"]==null)
                    return null;
                return thisNode.Attributes["returns"].Value;
            }
        }
    }
    public partial class Param
    {
        private XmlNode thisNode;
        public Param(XmlNode node) 
        {
            thisNode = node;
        }
        public string name
        {
            get
            {
                if (thisNode.Attributes["name"]==null)
                    return null;
                return thisNode.Attributes["name"].Value;
            }
        }
        public string type
        {
            get
            {
                if (thisNode.Attributes["type"]==null)
                    return null;
                return thisNode.Attributes["type"].Value;
            }
        }
        public string desc
        {
            get
            {
                if (thisNode.Attributes["desc"]==null)
                    return null;
                return thisNode.Attributes["desc"].Value;
            }
        }
    }
    public partial class Interface
    {
        private XmlNode thisNode;
        public Interface(XmlNode node) 
        {
            thisNode = node;
        }
        public string type
        {
            get
            {
                if (thisNode.Attributes["type"]==null)
                    return null;
                return thisNode.Attributes["type"].Value;
            }
        }
    }
    public partial class Event
    {
        private XmlNode thisNode;
        public Event(XmlNode node) 
        {
            thisNode = node;
        }
        public string name
        {
            get
            {
                if (thisNode.Attributes["name"]==null)
                    return null;
                return thisNode.Attributes["name"].Value;
            }
        }
        public string type
        {
            get
            {
                if (thisNode.Attributes["type"]==null)
                    return null;
                return thisNode.Attributes["type"].Value;
            }
        }
        public string access
        {
            get
            {
                if (thisNode.Attributes["access"]==null)
                    return null;
                return thisNode.Attributes["access"].Value;
            }
        }
        public string summary
        {
            get
            {
                if (thisNode.Attributes["summary"]==null)
                    return null;
                return thisNode.Attributes["summary"].Value;
            }
        }
    }
    public partial class EntityDefine
    {
        public EntityDefine(string fileName) 
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(fileName);
            thisNode = doc.SelectSingleNode("EntityDefine");
        }
        
        public EntityDefine(XmlDocument doc) 
        {
            thisNode = doc.SelectSingleNode("EntityDefine");
        }
        
    }
}
